<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<p>整数1：<input type="text" id="num1"></p>
<p>整数2：<input type="text" id="num2"></p>
<button onclick="p(1)">相加</button>
<button onclick="p(2)">相减</button>
<button onclick="p(3)">相乘</button>
<button onclick="p(4)">相除</button>
<p>结果：<input type="text" id="guo"></p>

<script>
    function p(x) {
        var n1=document.querySelector("#num1").value;
        var n2=document.querySelector("#num2").value;
        n1=Number(n1);
        n2=Number(n2);
        if(x==1){
            document.querySelector("#guo").value= n1 + n2;
        }
        if(x==2){
            document.querySelector("#guo").value= n1 - n2;
        }
        if(x==3){
            document.querySelector("#guo").value= n1 * n2;
        }
        if(x==4){
            document.querySelector("#guo").value= n1 / n2;
        }

    }
</script>
</body>
</html>